package dp.dayOne;

public class ThreeQuestion {
    //爬楼梯
    public int climbStairs(int n) {
        if (n<=2){
            return n;
        }
        int pre1 = 2,pre2 = 1,result = 0;
        for (int i = 3; i <= n; i++) {
            result = pre1+pre2;
            pre2=pre1;
            pre1 = result;
        }
        return result;
    }
}
